package com.tanhua.admin.controller;

import com.tanhua.admin.service.AnalysisService;
import com.tanhua.model.vo.AnalysisSummaryVo;
import com.tanhua.model.vo.SummaryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 后台控制面板统计
 */
@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private AnalysisService analysisService;


    /**
     * 控制面板概要信息统计
     * @return
     */
    @RequestMapping("/summary")
    public ResponseEntity summaryStatistics(){
        AnalysisSummaryVo summaryVo = analysisService.summaryStatistics();
        return ResponseEntity.ok(summaryVo);
    }

    /**
     * 新增、活跃用户、次日留存率
     * @param type
     * @param sd
     * @param ed
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity statisticsReport(String type,String sd,String ed){
        SummaryResult summaryResult = analysisService.statisticalReports(type,sd,ed);
        return ResponseEntity.ok(summaryResult);
    }
}
